package beanScope;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author quan
 * @Description TODO
 * @Date 2023/7/14 15:30
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        UserController1 controller1 = (UserController1) context.getBean("userController1");
        controller1.sayHi();

        UserController2 controller2 = (UserController2) context.getBean("userController2");
        controller2.sayHi();

//        //演示一个Application context下获取到的是同一个对象
//        ApplicationContext context1 = new ClassPathXmlApplicationContext("spring-config.xml");
//        UserController1 controller1 = (UserController1) context1.getBean("userController1");
//        System.out.println(controller1);//地址A
//
//        UserController1 controller2 = (UserController1) context1.getBean("userController1");
//        System.out.println(controller2);//地址A
//
//        ApplicationContext context2 = new ClassPathXmlApplicationContext("spring-config.xml");
//        UserController1 controller11 = (UserController1) context2.getBean("userController1");
//        System.out.println(controller11);//地址B
//
//        UserController1 controller22 = (UserController1) context2.getBean("userController1");
//        System.out.println(controller22);//地址B
    }
}
